package com.cnswhy.cloud.server.core.service.impl;


import com.cnswhy.cloud.common.core.mybatis.conditions.Wraps;
import com.cnswhy.cloud.server.core.dao.IotChargingLineScaleMapper;
import com.cnswhy.cloud.server.core.entity.IotChargingLineScale;
import com.cnswhy.cloud.server.core.service.IotChargingLineScaleService;
import com.cnswhy.cloud.common.core.base.service.SuperServiceImpl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 业务实现类
 * 
 * </p>
 *
 * @author cnswhy
 * @date 2021-04-09
 */
@Slf4j
@Service

public class IotChargingLineScaleServiceImpl extends SuperServiceImpl<IotChargingLineScaleMapper, IotChargingLineScale> implements IotChargingLineScaleService {
    @Override
    public void initSale(Long iotChargingLineInfoId) {
        for(int i = 0 ;i <= 10 ;i ++){
            if(i == 1 || i == 3 || i == 5 || i == 8){

                IotChargingLineScale iotChargingLineScale =
                        getOne(Wraps.<IotChargingLineScale>lbQ().eq(IotChargingLineScale::getTerminalId, iotChargingLineInfoId).eq(IotChargingLineScale::getHours,i));
                if(iotChargingLineScale == null){
                    iotChargingLineScale = new IotChargingLineScale();
                    iotChargingLineScale.setMenuAmt(10L);
                    iotChargingLineScale.setMerchantAmt(0L);
                    iotChargingLineScale.setHours(i);
                    iotChargingLineScale.setTerminalId(iotChargingLineInfoId);
                    iotChargingLineScale.setMenuName(String.format("%d小时", i));
                    save(iotChargingLineScale);
                }
            }
        }

    }
}
